<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>02使用canvas绘制矩形</title>
  <style>
    canvas {
      border: 1px solid #333;
    }
  </style>
</head>
<body>
  <canvas id="canvas" width="800" height="600"></canvas>

  <script>
    // 获取页面中的标签对象
    const canvas = document.getElementById('canvas')
    // 获取画笔对象
     const ctx = canvas.getContext('2d')
    // 画图
    ctx.strokeStyle='orange'; // 更改颜色
    ctx.strokeRect(200,200,160,-180)

    ctx.fillStyle = 'purple' // 更改颜色
    ctx.fillRect(200,430,160,120)
  </script>
</body>
</html>